<template>
  <div class="page-container">
    <pf-table
      ref="pfTable"
      v-model="form"
      :columns="columns"
      :form-items="formItems"
      @get-table-data="getTableData"
    >
      <template #handle="{row}">
        <el-button type="text" size="small" @click="gotoDetail(row)">详情</el-button>
      </template>
    </pf-table>
  </div>
</template>

<script>
export default {
  name: 'PaymentList',
  components: {},
  props: {},
  data() {
    return {
      form: {}
    }
  },
  computed: {
    columns() {
      const attrs = { 'min-width': '150px' }
      return [
        { label: '消费时间', prop: 'title', attrs },
        { label: '车牌号', prop: 'views', attrs },
        { label: '停车时长', prop: 'createTime', attrs },
        { label: '账单总金额', prop: 'creator', attrs },
        { label: '已付金额', prop: 'creator', attrs },
        { label: '优惠金额', prop: 'creator', attrs },
        { label: '实付金额', prop: 'creator', attrs },
        { label: '停车场名称', prop: 'creator', attrs },
        { label: '支付方式', prop: 'creator', attrs },
        { label: '操作', slot: 'handle', attrs: { width: '150px', fixed: 'right' }}
      ]
    },
    formItems() {
      return [
        {
          type: 'input',
          label: '车牌号',
          prop: 'title'
        }, {
          type: 'date',
          label: '消费时间',
          prop: 'dateRange',
          span: 8,
          attrs: {
            type: 'datetimerange'
          }
        }
      ]
    }
  },
  created() {},
  methods: {

    getTableData({ pageNo, pageSize, ...formQuery }, done) {
      // this.loading = true
      // const [createStartTime = '', createEndTime = ''] = formQuery?.dateRange || []
      // const data = {
      //   pageNo,
      //   pageSize,
      //   createStartTime,
      //   createEndTime,
      //   ...formQuery
      // }
      // getEnterList(data).then(res => {
      //   this.loading = false
      //   done({ data: res.data || [], total: res.count || 0 })
      // }).catch(() => {
      //   done({ data: [], total: 0 })
      //   this.loading = false
      // })

      done({ data: [{ id: 1 }], total: 0 })
    },

    // 跳转详情
    gotoDetail(row) {
      this.$router.push({
        path: '/service/parking/detail',
        query: {
          id: row.id
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
